﻿namespace apitest.Application.Entities.Pms
{

    [SugarTable("TestRequest")]
    public class TestRequest
    {
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
        public int Id { get; set; }
        /// <summary>
        /// 请检单号
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// 项目等级
        /// </summary>
        public string ProjectLevel { get; set; }

        /// <summary>
        /// 项目号
        /// </summary>
        public string ProjectCode { get; set; }
        public string CatNo { get; set; }
        /// <summary>
        /// 请检部门
        /// </summary>
        public string DepartmentName { get; set; }
        /// <summary>
        /// 请检人
        /// </summary>
        public int CreateUserId { get; set; }
        /// <summary>
        /// 实验室
        /// </summary>
        public int LabId { get; set; }
        /// <summary>
        /// 请检日期
        /// </summary>
        public DateTime CreateTime { get; set; }
        /// <summary>
        /// 其他检测方法
        /// </summary>
        public string TestOther { get; set; }
        /// <summary>
        /// 请检批号
        /// </summary>
        public string BatchNo { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }
        /// <summary>
        /// 结构式
        /// </summary>
        public int StructureId { get; set; }
        /// <summary>
        /// 检测方法
        /// </summary>
        public string TestMethod { get; set; }
        /// <summary>
        /// 检测条件说明
        /// </summary>
        public string Description { get; set; }
        /// <summary>
        /// 是否加急
        /// </summary>
        public bool Urgent { get; set; }
        /// <summary>
        /// 预测获取结果时间
        /// </summary>
        public DateTime? PredictDate { get; set; }
        /// <summary>
        /// 请检单接收时间
        /// </summary>
        public DateTime? ReceiveDate { get; set; }
        /// <summary>
        /// 接收人
        /// </summary>
        public int ReceiveUserId { get; set; }
        /// <summary>
        /// 检测能力
        /// </summary>
        public string TestCategorys { get; set; }
        /// <summary>
        /// 状态
        /// </summary>
        public TestRequestStatusEnums Status { get; set; }
        /// <summary>
        /// 确认人ID
        /// </summary>
        public int AuditUserId { get; set; }
        public DateTime? AuditTime { get; set; }
        public string AuditRemark { get; set; }
        public bool? AuditResult { get; set; }
        public string Structure { get; set; }
        public bool PreUrgent { get; set; }
        public int? UrgentAuditUserId { get; set; }
        public DateTime? UrgentAuditTime { get; set; }
        public string UrgentAuditRemark { get; set; }
        public bool? UrgentAuditResult { get; set; }
        public string TestType { get; set; }
        /// <summary>
        /// 送样人ID
        /// </summary>
        public int? SampleUserId { get; set; }
        public string SampleUserName { get; set; }
        /// <summary>
        /// 产品预计检测周期
        /// </summary>
        public double? ExpectDay { get; set; }
        /// <summary>
        /// 产品检测是否方法
        /// </summary>
        public string HasMethod { get; set; }
        /// <summary>
        /// 整个检测完成日期
        /// </summary>
        public DateTime? FinishDate { get; set; }
    }

    //    (names, userIds, orgName) = await GetDepManagerAsync(p.UserId, 2);
    public enum TestRequestStatusEnums
    {
        草稿 = 0,
        已提交 = 1,
        样品接收 = 2,
        检测中 = 3,
        检测结束 = 4
    }


    [SugarTable("TestRequestRecord")]
    public class TestRequestRecord
    {
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
        public int Id { get; set; }

        /// <summary>
        /// 请检单ID
        /// </summary>
        public int TestRequestId { get; set; }

        /// <summary>
        /// 仪器名称
        /// </summary>
        public string InstrumentName { get; set; }
        /// <summary>
        /// 仪器位置
        /// </summary>
        public string InstrumentSlot { get; set; }
        /// <summary>
        /// 检测人
        /// </summary>
        public int? TestUserId { get; set; }
        /// <summary>
        /// 检测方法
        /// </summary>
        public string TestMethod { get; set; }
        /// <summary>
        /// 检测能力
        /// </summary>
        public string TestCategory { get; set; }
        /// <summary>
        /// 其他检测能力
        /// </summary>
        public string TestOther { get; set; }
        /// <summary>
        /// 检测条件说明
        /// </summary>
        public string Description { get; set; }
        /// <summary>
        /// 检测完成时间
        /// </summary>
        public DateTime? ResultDate { get; set; }

        /// <summary>
        /// 检测结果
        /// </summary>
        [SugarColumn(ColumnDataType = "xml")]
        public string? Result { get; set; }

      

        /// <summary>
        /// 状态
        /// </summary>
        public TestRequestRecordStatusEnums Status { get; set; }

        /// <summary>
        /// 检测开始时间
        /// </summary>
        public DateTime? StartDate { get; set; }

        /// <summary>
        /// 检测预计完成时间
        /// </summary>
        public DateTime? ExpectResultDate { get; set; }

        /// <summary>
        /// 检测使用时间
        /// </summary>
        public double? DuringDate { get; set; }

        /// <summary>
        /// 是否超时
        /// </summary>
        public bool IsTimeout { get; set; }
        /// <summary>
        /// 是否加急
        /// </summary>
        public bool Urgent { get; set; }

        /// <summary>
        /// 接收人
        /// </summary>
        public int? ReceiveUserId { get; set; }

        /// <summary>
        /// 接收时间
        /// </summary>
        public DateTime? ReceiveDate { get; set; }

        /// <summary>
        /// 分配人
        /// </summary>
        public int? DistributeUserId { get; set; }

        /// <summary>
        /// 分配时间
        /// </summary>
        public DateTime? DistributeDate { get; set; }

        /// <summary>
        /// 复核人id
        /// </summary>
        public int? ReCheckUserId { get; set; }

        /// <summary>
        /// 复核时间
        /// </summary>
        public DateTime? ReCheckDate { get; set; }

        /// <summary>
        /// 复核结果文字
        /// </summary>
        public string ReCheckRemark { get; set; }

        /// <summary>
        /// 复核结果
        /// </summary>
        public bool? ReCheckResult { get; set; }

        /// <summary>
        /// 取消原因
        /// </summary>
        public string CancleReason { get; set; }
        /// <summary>
        /// 方法开发的难度
        /// </summary>
        public string Level { get; set; }
        /// <summary>
        /// 方法开发最终确认的方法
        /// </summary>
        public string LastMethod { get; set; }
        /// <summary>
        /// 移交原因
        /// </summary>
        public string TransferReason { get; set; }
        /// <summary>
        /// 配样人员
        /// </summary>
        public int? OperatUserId { get; set; }
        /// <summary>
        /// 针数
        /// </summary>
        public int Needles { get; set; }
        /// <summary>
        /// 产品检测是否合格
        /// </summary>
        public bool Deviation { get; set; }
        /// <summary>
        /// 产品检测是否偏差
        /// </summary>
        public bool Qualified { get; set; }
        /// <summary>
        /// 产品检测OOS
        /// </summary>
        public bool OOS { get; set; }
        /// <summary>
        /// 不合格备注
        /// </summary>
        public string DeviationRemark { get; set; }
        /// <summary>
        /// 偏差备注
        /// </summary>
        public string QualifiedRemark { get; set; }
        /// <summary>
        /// OOS备注
        /// </summary>
        public string OOSRemark { get; set; }
        /// <summary>
        /// 偏差人为或非不为
        /// </summary>
        public string QualifiedType { get; set; }
        /// <summary>
        /// OOS人为或非不为
        /// </summary>
        public string OOSType { get; set; }
        public string DeviationItem { get; set; }
        public string QualifiedItem { get; set; }
        public string OOSItem { get; set; }
        public string DelayItem { get; set; }
        public string DelayRemark { get; set; }
        public string Weight { get; set; }
    }

    /// <summary>
    /// 仪器表
    /// </summary>
    [SugarTable("TestInstrument")]
    [Tenant("USER")]
    public class TestInstrument
    {
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
        public int Id { get; set; }

        public string Code { get; set; }
    }
    public enum TestRequestRecordStatusEnums
    {
        未接收 = 0,
        未分配 = 1,
        检测中 = 2,
        完成 = 3,
        取消 = 4
    }


}